package uba.ing2.subite.domain;

import java.util.Date;

import uba.ing2.subite.util.DateUtil;

public abstract class AbstractAccountEntry implements AccountEntry {
	private final Date date;
	private final Number value;
	private final String description;

	public AbstractAccountEntry(Date date, Number value, String description) {
		if (value.doubleValue() < 0) throw new IllegalArgumentException("El valor no puede ser negativo");

		this.date = date;
		this.value = value;
		this.description = description;
	}

	@Override
	public Date date() {
		return date;
	}

	@Override
	public String description() {
		return description;
	}

	protected Number value() {
		return value;
	}

	@Override
	public boolean isFor(Date date) {
		return DateUtil.equalsWithoutTime(this.date, date);
	}
}
